﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Text;
using OgilvyOne.BLL;
using OgilvyOne.Model;
using OgilvyOne.UKNow.BLL;
using OgilvyOne.UKNow.Model;
using System.Collections.Generic;

public partial class admin_infomation_info_map_list : AdminBasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            var og = Request.QueryString[""];
            this.headers.Text = new ColumnBll().LayeridColumnConNaiv(Request.Params["layerid"]);
            Grid_viewBild("");
        }
        else
        {
            if (Request.Form["pageNum"]!=null)
            {
                pagePadding(Request.Form["pageNum"].ToString());
            }
        }
    }
    //添加按钮
    protected void Add_click(object sender, EventArgs e)
    {
        this.PopedomValidate(Request.Params["layerid"], ADD);
        Response.Redirect("Audio_Edit.aspx?columnid=" + Request.Params["columnid"] + "&layerid=" + Request.Params["layerid"] + "&langid=" + Request.QueryString["langid"] , true);
    }
    //修改按钮
    protected void Mod_click(object sender, EventArgs e)
    {

        this.PopedomValidate(Request.Params["layerid"], MOD);
        Response.Redirect("Audio_Edit.aspx?columnid=" + Request.Params["columnid"] + "&layerid=" + Request.Params["layerid"] + "&langid=" + Request.Params["langid"] + "&id=" + ((LinkButton)sender).CommandArgument, true);
    }
    //删除按钮
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        GridView gv = (GridView)sender;
        int mid = int.Parse(gv.DataKeys[e.RowIndex].Value.ToString());
        bool bl = new AudioBLL( Convert.ToInt32( Request.QueryString["langid"])).del(mid);
        if (bl == true)
        {
            Response.Write("<script>alert('删除成功!')</script>");
            Grid_viewBild("");
        }
        else
        {
            Response.Write("<script>alert('删除失败!')</script>");
        }
    }
    //绑定方法
    private void Grid_viewBild(string key)
    {
        AudioBLL audbll = new AudioBLL(Convert.ToInt32( Request.QueryString["langid"]));
        List<Audio> laud = new List<Audio>();
        if (key == "true" || key == "false")
        {
            laud=Convert.ToBoolean(key)?audbll.getALLRele():audbll.getALLnoRele();
        }
        else
        {
             laud = key.Trim() == ""||key.Trim()=="$" ? audbll.getALL() : audbll.find(key.Trim());
        }
        GridView1.DataSource = laud;
        GridView1.AllowPaging = true;
        GridView1.DataBind();
        this.pagehtml.Text = getPageHtml(GridView1.PageCount, GridView1.PageIndex + 1, laud.Count);
    }
    protected void btnFind_Click(object sender, EventArgs e)
    {
        Grid_viewBild(keyword.Text);
    }
    protected void qdocstate_SelectedIndexChanged(object sender, EventArgs e)
    {
        Grid_viewBild(qdocstate.SelectedValue);
    }
    protected void rows_SelectedIndexChanged(object sender, EventArgs e)
    {
        GridView1.PageSize = int.Parse( rows.SelectedValue);

        Grid_viewBild(qdocstate.SelectedValue);

    }
    private void pagePadding(string pindex)
    {

        GridView1.PageIndex = int.Parse(pindex)-1;
        Grid_viewBild(qdocstate.SelectedValue);
    }
}
